<%-- 
    Document   : bookDtails
    Created on : 2015-6-27, 11:16:47
    Author     : MY
--%>

<%@page import="java.util.List"%>
<%@page import="bookstore.model.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>图书详细页</title>
        <link rel="stylesheet" href="/iBook/css/all.css" type="text/css"/>
        <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">
    </head>
    <body>
        <%
        int i = Integer.parseInt( request.getParameter("list_index"));
        List<Book> list = (List<Book>) session.getAttribute("bookList");
        Book book = list.get(i);
    %>
        <jsp:include  page="/common/top.jsp"/>
        <div class="container">
            <div class="row">
                <div class="col-md-6" style="position: relative">
                    <div class="thumbnail" style="width: 200px;height: 280px; position: absolute; right: 0 ">
                        <img src="/iBook/bookimages/<%=book.getPicture()%>" alt="..." style="display:block;width:100%;height: 100%;">
                    </div>
                </div>
                <div class="col-md-6">
                    <h3><b><%=book.getName()%></b></h3>
                    <h4><%=book.getDesc()%></h4>
                    <h5><strong>定价</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;￥<%=book.getPrice()%></h5>
                    <h5><strong>作者</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=book.getAuthor()%></h5>
                    <h5><strong>出版社</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=book.getPublisher()%></h5>
                    <h5><strong>ISBN</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=book.getIsbn()%></h5>
                    <h5><strong>所属分类</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=book.getCategory().getName()%></h5>
                    <p>
                    <form action="/iBook/AddToCar.action?list_index=<%=i %>" method="POST">
                    <div class="input-group " style="width:110px;height: 10px">
                        <span class="input-group-btn">
                            <button id="bookMinus" class="btn btn-default btn-sm" type="button"><span class="glyphicon glyphicon-minus" aria-hidden="true"></span></button>
                        </span>
                        <input type="text" id="bookCount" name="count" class="form-control input-sm text-center" value="1">
                        <span class="input-group-btn">
                            <button id="bookAdd" class="btn btn-default btn-sm" type="button"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
                        </span>         
                    </div>
                         <br/>
                         <div><strong>总价:    <span id="sum" name="sum"><%=book.getPrice()%></span>￥</strong></div> 
                    <br/>
                   <button type="submit" class="btn btn-danger btn-lg">加入购物车</button>
                    </form>
                    </p>
                </div>
            </div>
        </div>
                    <jsp:include  page="/common/bottom.jsp"/>
                    <script src="/iBook/js/jquery.min.js" type="text/javascript"></script>
                    <script type="text/javascript">
                        $("#bookMinus").click(function(){
                           var count = $("#bookCount").val();
                           --count;
                            $("#bookCount").val(count);
                            var simple = <%=book.getPrice() %>;
                            var sum = count * simple;
                             $("#sum").text(sum);
                        });
                        $("#bookAdd").click(function(){
                           var count = $("#bookCount").val();
                          ++count;
                            $("#bookCount").val(count); 
                            var simple = <%=book.getPrice() %>;
                            var sum = count * simple;
                            $("#sum").text(sum);
                        });
                        $("#bookCount").keyup(function(){
                           var count = $("#bookCount").val();
                            var simple = <%=book.getPrice() %>;
                            var sum = count * simple;
                            $("#sum").text(sum);
                        });
                    </script>
    </body>
</html>
